package org.imlinker.plugin;

import java.io.File;
import java.util.ArrayList;

import org.imlinker.core.Core;
import org.jivesoftware.smack.Chat;

public class Plugin {

	public Plugin(final String paraName) {
		this.name = paraName;
	}

	public PluginAccount getAccount(String id, boolean createFirst) {
		if (createFirst) {
			return AccountManager.createAccount(name, id);
		}

		return AccountManager.getAccount(name, id);
	}

	public boolean getBooleanAt(final String url) {
		return Core.getBooleanAt(name + "." + url);
	}

	public File getFile(String fileName) {
		return ResourceManager.getFile(name, fileName);
	}

	public String getValue(final String url) {
		return Core.getValue(name + "." + url);
	}

	public void open() {
	}

	public void setValueAt(final String url, final String value) {
		Core.setValueAt(name + "." + url, value);
	}

	public void deleteValue(final String url) {
		Core.deleteValue(name + "." + url);
	}

	public int getElementSize(final String url) {
		return Core.getElementSize(name + "." + url);
	}

	public void save() {
		Core.save();
	}

	public Chat getChat(String chatName) {
		return ResourceManager.getChat(chatName);
	}

	public ArrayList<String> getBuddyNamse() {
		return ResourceManager.getBuddyNames();
	}

	private String name;

}
